package com.zxmc.server.controller.user;

import com.zxmc.common.result.Result;
import com.zxmc.pojo.entity.Author;
import com.zxmc.pojo.entity.BookShelf;
import com.zxmc.server.service.AuthorService;
import com.zxmc.server.service.BookShelfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/bookShelf")
@Slf4j
@Api(tags = "书架相关接口")
public class BookShelfController {

    @Autowired
    private BookShelfService bookShelfService;
    @GetMapping("/list")
    @ApiOperation("查询书架数据")
    public Result<List<BookShelf>> list(Integer id) {
        log.info("查询书架数据，{}",id);
        return Result.success(bookShelfService.list(id));
    }

    @PostMapping("/insert/{id}")
    @ApiOperation("添加书架数据")
    public Result insert(@PathVariable Integer id) {
        log.info("添加书架数据，{}",id);
        bookShelfService.insert(id);
        return Result.success();
    }
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除书架数据")
    public Result delete(@PathVariable Integer id) {
        log.info("删除书架数据，{}",id);
        bookShelfService.delete(id);
        return Result.success();
    }
}
